package GUI;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.*;
import javax.swing.border.EmptyBorder;

public class Delivery extends JFrame {

	private JPanel contentPane;
	private Success suc;
	
	/**
	 * Create the frame.
	 */
	public Delivery(String s) {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 220, 130);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JButton btnSave = new JButton("Save");
		if(s.equals("new"))
		{
			setTitle("Add delivery type");
			btnSave.addMouseListener(new MouseAdapter() {
				@Override
				public void mouseClicked(MouseEvent arg0) {
					suc=new Success("cr", false);
					suc.setVisible(true);
					dispose();
				}
			});
			btnSave.setBounds(109, 61, 89, 23);
			contentPane.add(btnSave);
		}
		else
		{
			setTitle("Manage delivery type");
			btnSave.addMouseListener(new MouseAdapter() {
				@Override
				public void mouseClicked(MouseEvent arg0) {
					suc=new Success("mng", false);
					suc.setVisible(true);
					dispose();
				}
			});
			btnSave.setBounds(109, 61, 89, 23);
			contentPane.add(btnSave);
		}
		
		JLabel lblName = new JLabel("Name:");
		lblName.setBounds(10, 11, 66, 14);
		contentPane.add(lblName);
		
		JLabel lblPrice = new JLabel("Price/km:");
		lblPrice.setBounds(10, 36, 66, 14);
		contentPane.add(lblPrice);
		
		JTextField txtName = new JTextField();
		txtName.setBounds(86, 8, 100, 17);
		contentPane.add(txtName);
		txtName.setColumns(10);
		
		JTextField txtDiscount = new JTextField();
		txtDiscount.setBounds(86, 33, 100, 17);
		contentPane.add(txtDiscount);
		txtDiscount.setColumns(10);
		
		JButton btnCancel = new JButton("Cancel");
		btnCancel.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				MainMenu.getInstance().setVisible(true);
				dispose();
			}
		});
		btnCancel.setBounds(10, 61, 89, 23);
		contentPane.add(btnCancel);
	}

}
